﻿package birdry.ui	{
	import flash.display.MovieClip;
	import flash.display.Stage;
	
	import caurina.transitions.Tweener;
	
	/**
	 * ...
	 * @author 
	 */
	public class  Alert 	{
		
		
		private static var _stage:Stage;
		private static var _alertMc:MovieClip;
		
		public static var alphaSpeed:Number = 0;
		public static var motionSpeed:Number = 0.5;
		public static var transition:String = "easeOutElastic";
		public static var distanceX:Number = 0;
		public static var distanceY:Number = 0;
		
		public function Alert(): void	{
			
		}
		
		public static function open( stage: Stage, alertMc:MovieClip ): void	{
			_stage = stage;
			_alertMc = alertMc;
			var positionX:int = (stage.stageWidth - alertMc.width) / 2;
			var positionY:int = (stage.stageHeight - alertMc.height) / 2;
			alertMc.x = positionX;
			alertMc.y = positionY;
			stage.addChild(alertMc);
			alertMc.alpha = 0;
			Alert.motionPlay(); 
		}
		
		private static function motionPlay(): void	{
			var alertMc:MovieClip = Alert._alertMc;
			alertMc.x += distanceX;
			alertMc.y += distanceY;
			Tweener.addTween(alertMc, { alpha:1, time:alphaSpeed } );
			Tweener.addTween(alertMc, { x:alertMc.x - distanceX, y:alertMc.y - distanceY, time:motionSpeed, transition:transition} );
		}
		
		public static function close( alertMc:MovieClip ): void	{
			_stage.removeChild(alertMc);
		}
	}
}